import {AccessToken} from "../base/constants";
import AsyncStorage from "@react-native-async-storage/async-storage";

const getToken = () => {
    return new Promise((resolve, reject) => {
        AsyncStorage.getItem(AccessToken).then(token => {
            resolve(token);
        }).catch(reason => {
            reject(reason);
        });
    });
}

const updateToken = token => {
    return new Promise(resolve => {
        AsyncStorage.setItem(AccessToken, token).then(() => {
            resolve();
        })
    })
}

const removeToken = () => {
    return new Promise(resolve => {
        AsyncStorage.removeItem(AccessToken, () => {
            resolve();
        });
    });
}

export default {
    getToken,
    updateToken,
    removeToken
}
